const fs = require('fs');
var rootpath = '../static/setIndir';
var runs = function(time,name){
    var data = new Date().getTime();
    var cha = Number(data) - Number(time);
    if(cha == NaN) return;
    if(cha>=0){
        fs.unlinkSync(rootpath + '/' + name);
    };
    // console.log(cha / 1000)
};
module.exports = function(obj={}){
    setInterval(function(){
        var files = fs.readdirSync(obj.dir?obj.dir:rootpath) 
        for(var i in files){
            let o = files[i].split('.')[0];
            runs(o,files[i]);
        }
    },obj.time?obj.time:1000*60*60*24)
}
